<%--
  Created by IntelliJ IDEA.
  User: lww
  Date: 2019/1/10
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>采购退货</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <script src="/layuiadmin/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<div class="layui-form layui-from-item" action="" style="margin-left: 20px;margin-top: 20px">
    <div class="layui-inline">
        <%--<label class="layui-form-label con1">客户名称：</label>--%>
        <div class="layui-input-inline">票据号:&nbsp</div>
        <div class="layui-input-inline" style="width: 200px;">
            <input type="text" name="number" id="number" placeholder="票据号" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">操作员:&nbsp</div>
        <div class="layui-input-inline" style="width: 150px;">
            <input type="text" name="operpersonname" id="operpersonname" placeholder="操作员" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">&nbsp创建时间：</div>
        <div class="layui-input-inline" style="width: 120px;">
            <input  type="text" id="d1" name="d1"  placeholder="起始时间" class="layui-input">
        </div>
        <div class="layui-input-inline">-</div>
        <div class="layui-input-inline" style="width: 120px;">
            <input  type="text" id="d2" name="d2"  placeholder="截止时间" class="layui-input">
        </div>
    </div>
    <div class="layui-inline" style="">
        <button type="button" style="margin-left: -3px" class="layui-btn" id="chaxun">查询</button>
        <button type="reset" class="layui-btn" style="margin-left: -3px" id="add">添加</button>
        <button type="reset" class="layui-btn" style="margin-left: -3px">删除选中</button>
    </div>
</div>

<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
        <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
    </div>
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<%--<script src="/layuiadmin/layui/layui.js" charset="utf-8"></script>--%>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['table','jquery','laydate','layer','laypage'], function(){
        var table = layui.table;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var laypage = layui.laypage;
        $ = layui.jquery;
        var tableIns=table.render({
            elem: '#test'
            ,url:'/depotheadout/select'
            ,toolbar: '#toolbarDemo'
            ,page: true
            ,id: "tests"
            ,title: '采购退货表'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true}
                ,{field:'type', title:'类型(出库/入库)', width:80,edit: 'text'}
                ,{field:'subtype', title:'出入库分类', width:100,edit: 'text'}
                ,{field:'number', title:'票据号', width:165, edit: 'text'}
                ,{field:'organid', title:'供应商', width:80,edit: 'text'}
                ,{field:'operpersonname', title:'操作员', width:100, edit: 'text'}
                ,{field:'createtime', title:'创建时间', width:155,edit: 'text'}
                ,{field:'othermoney', title:'费用合计', width:80,edit: 'text'}
                ,{field:'remark', title:'备注', width:125,edit: 'text'}
                ,{field:'status', title:'单据状态', width:100,edit: 'text'}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:170}
            ]]
        });
        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    layer.msg('选中了：'+ data.length + ' 个');
                    break;
                case 'isAll':
                    layer.msg(checkStatus.isAll ? '全选': '未全选');
                    break;
            };
        });
        //弹出日历框
        laydate.render({
            elem:'#d1'
        });
        //弹出日历框
        laydate.render({
            elem:'#d2'
        });
        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                    /*执行删除操作*/
                    $.ajax({
                        url:"/depotheadout/delete?id="+data.id,
                        success:function (data) {
                            alert(data.code);
                        }
                    })
                });
            } else if(obj.event === 'edit'){
                layer.prompt({
                    formType: 2
                    ,value: data.email
                }, function(value, index){
                    obj.update({
                        email: value
                    });
                    layer.close(index);
                });
            }
        });
        $(function () {
            /*模糊查询*/
            $("#chaxun").on("click",function(){
                var  number = $("#number").val();
                var operpersonname = $("#operpersonname").val();
                tableIns.reload({
                    where :{//设定异步数据接口的额外参数，任意设
                        number:number,
                        operpersonname:operpersonname
                    },page:{
                        curr:1 //从新从第一页开始
                    }
                });
            });
            $("#add").on("click",function () {
                layer.open({
                    type: 2,
                    content: '/erp_purchase/addout', //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                    area: ['650px', '600px']
                });
            });
        });
    });
</script>

</body>
</html>